import {createRouter, createWebHashHistory } from 'vue-router'
import Login from "@/components/Login";
import Search from "@/components/Search";
import Reader from "@/components/Reader";
import ReaderSearch from "@/components/Reader/ReaderSearch";
import ReaderInfo from "@/components/Reader/ReaderInfo";
import ReaderHistory from "@/components/Reader/ReaderHistory";
// 2. 定义一些路由
// 每个路由都需要映射到一个组件。
const routes = [
    { path: '/Search', component: Search },
    { path: '/Login', component: Login },
    { path: '/Reader', component: Reader ,
    children: [
        {
            path: "/Reader/ReaderSearch",
            name: "ReaderSearch",
            component: ReaderSearch
        },
        {
            path: "/Reader/ReaderHistory",
            name: "ReaderHistory",
            component: ReaderHistory
        },
        {
            path: "/Reader/ReaderInfo",
            name: "ReaderInfo",
            component: ReaderInfo
        }
    ]},
    { path: '/:catchAll(.*)', redirect: '/Search' },
]

// 3. 创建路由实例并传递 `routes` 配置
// 你可以在这里输入更多的配置，但我们在这里
// 暂时保持简单
const router = createRouter({
    // 4. 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    history: createWebHashHistory(),
    // history: createWebHistory(),
    routes, // `routes: routes` 的缩写
})
export default router